package net.ojbk.saishi.dao;

import java.sql.ResultSet;
import java.sql.Statement;

import net.ojbk.database.DatabaseConnection;

public class UserDataDaoV2 {
	static final String tableName="userData";
	DatabaseConnection dbconn;
	Statement stmt;
	public UserDataDaoV2(DatabaseConnection dbconn) {
		this.dbconn = dbconn;
		stmt=dbconn.getStatement();
	}
	
	public String getEmailByUserId(String userId) {
		if (userId == null || userId.equals("null")) return "null";
		String flag = "null";
		ResultSet re;
		try {
			String sql="select * from "
					+ tableName
					+ " where id='"
					+ userId
					+"';";
			re = stmt.executeQuery(sql);
			if (re.next()) {
				return re.getString("email");
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
		return flag;
	}
	
	
}
